import { pinyin } from "pinyin-pro";
function getDwType(arr) {
  var newArr = [];

  arr.forEach((item) => {
        //判断类型
    var chineseText = Typejudgment(item.alarmEventtype);

    var pinyinArray = pinyin(chineseText, { toneType: "none" });
  
    item.type = chineseText;
    item.imageType = pinyinArray;

    var colors = getColorTranslation(item.alarmSeverity);

    item.imageType = item.imageType.replace(/\s/g, "");
 
    if (colors == "红色") {
      item.degree = "red";
    } else if (colors == "橙色") {
     
      item.degree = "orange";
    } else if (colors == "黄色") {
      item.degree = "yellow";
    } else if (colors == "蓝色") {
      item.degree = "blue";
    }

    newArr.push(item);
  });
  return newArr;
}
//颜色对照表
function getColorTranslation(color) {
  switch (color) {
    case "Red":
      return "红色";
      break;

    case "Orange":
      return "橙色";
      break;

    case "Yellow":
      return "黄色";
      break;

    case "Blue":
      return "蓝色";
      break;

    default:
      return "Unknown Color";
  }
}
//类型判断
function Typejudgment(eventTypeCode) {
  switch (eventTypeCode) {
    case "10000":
      return "突发";
    case "11000":
      return "自然灾害";
    case "11A00":
      return "水旱灾害";
    case "11A01":
      return "洪水";
    case "11A02":
      return "内涝";
    case "11A03":
      return "水库重大险情";
    case "11A04":
      return "堤防重大险情";
    case "11A05":
      return "凌汛灾害";
    case "11A06":
      return "渍涝";
    case "11A07":
      return "洪涝";
    case "11A08":
      return "枯水";
    case "11A09":
      return "中小河流洪水和山洪气象风险";
    case "11A10":
      return "农村人畜饮水困难";
    case "11A11":
      return "中小河流洪水气象风险";
    case "11A13":
      return "防汛抗旱风险提示";
    case "11A14":
      return "城市内涝风险";
    case "11A51":
      return "山洪灾害";
    case "11A52":
      return "农业干旱";
    case "11A53":
      return "城镇缺水";
    case "11A54":
      return "生态干旱";
    case "11A55":
      return "灾害风险预警";
    case "11A56":
      return "山洪灾害气象风险";
    case "11A57":
      return "山洪灾害气象";
    case "11A58":
      return "水利旱情";
    case "11A99":
      return "其它水旱灾害";
    case "11B00":
      return "气象灾害";
    case "11B01":
      return "台风";
    case "11B02":
      return "龙卷风";
    case "11B03":
      return "暴雨";
    case "11B04":
      return "暴雪";
    case "11B05":
      return "寒潮";
    case "11B06":
      return "大风";
    case "11B07":
      return "沙尘暴";
    case "11B08":
      return "低温冻害";
    case "11B09":
      return "高温";
    case "11B10":
      return "热浪";
    case "11B11":
      return "干热风";
    case "11B12":
      return "下击暴流";
    case "11B13":
      return "雪崩";
    case "11B14":
      return "雷电";
    case "11B15":
      return "冰雹";
    case "11B16":
      return "霜冻";
    case "11B17":
      return "大雾";
    case "11B18":
      return "低空风切变";
    case "11B19":
      return "霾";
    case "11B20":
      return "雷雨大风";
    case "11B21":
      return "道路结冰";
    case "11B22":
      return "干旱";
    case "11B23":
      return "海上大风";
    case "11B24":
      return "高温中暑";
    case "11B25":
      return "森林火险";
    case "11B26":
      return "草原火险";
    case "11B27":
      return "冰冻";
    case "11B28":
      return "空间天气";
    case "11B29":
      return "重污染";
    case "11B30":
      return "低温雨雪冰冻";
    case "11B31":
      return "强对流";
    case "11B32":
      return "臭氧";
    case "11B33":
      return "大雪";
    case "11B34":
      return "寒冷";
    case "11B35":
      return "连阴雨";
    case "11B36":
      return "渍涝风险";
    case "11B37":
      return "地质灾害";
    case "11B38":
      return "强降雨";
    case "11B39":
      return "强降温";
    case "11B40":
      return "雪灾";
    case "11B41":
      return "森林（草原）火险";
    case "11B42":
      return "医疗气象";
    case "11B43":
      return "雷暴";
    case "11B44":
      return "停课信号";
    case "11B45":
      return "停工信号";
    case "11B46":
      return "海上风险";
    case "11B47":
      return "春季沙尘天气趋势预警";
    case "11B48":
      return "降温";
    case "11B49":
      return "台风暴雨";
    case "11B50":
      return "严寒";
    case "11B51":
      return "沙尘";
    case "11B52":
      return "海上雷雨大风";
    case "11B53":
      return "海上大雾";
    case "11B54":
      return "海上雷电";
    case "11B55":
      return "海上台风预警信号";
    case "11B56":
      return "低温";
    case "11B57":
      return "道路冰雪";
    case "11B58":
      return "雷暴大风";
    case "11B59":
      return "持续低温";
    case "11B60":
      return "能见度不良";
    case "11B61":
      return "浓浮尘";
    case "11B62":
      return "海区大风";
    case "11B63":
      return "短历时强降水";
    case "11B64":
      return "短时强降雨";
    case "11B65":
      return "海区大雾";
    case "11B66":
      return "中暑气象条件";
    case "11B67":
      return "重污染天气";
    case "11B68":
      return "一氧化碳中毒气象条件 ";
    case "11B69":
      return "感冒等呼吸道疾病气象条件";
    case "11B71":
      return "腹泻等肠道疾病气象条件";
    case "11B72":
      return "心脑血管疾病气象条件";
    case "11B73":
      return "洪涝灾害气象风险";
    case "11B74":
      return "重污染气象条件";
    case "11B75":
      return "城市内涝气象风险";
    case "11B76":
      return "洪水灾害气象风险";
    case "11B77":
      return "森林火险气象风险";
    case "11B78":
      return "气象干旱";
    case "11B79":
      return "农业气象风险";
    case "11B80":
      return "强季风";
    case "11B81":
      return "电线积冰";
    case "11B82":
      return "脑卒中气象风险";
    case "11B84":
      return "森林（草原）火灾气象风险";
    case "11B85":
      return "雷雨强风";
    case "11B86":
      return "低温凝冻";
    case "11B87":
      return "低温冷害";
    case "11B88":
      return "全国农业气象灾害风险";
    case "11B89":
      return "冬小麦干热风灾害风险预警";
    case "11B99":
      return "其它气象灾害";
    case "11C00":
      return "地震灾害";
    case "11C01":
      return "人工地震";
    case "11C02":
      return "天然地震";
    case "11C03":
      return "地震速报信息";
    case "11C99":
      return "其它地震灾害";
    case "11D00":
      return "地质灾害";
    case "11D01":
      return "滑坡";
    case "11D02":
      return "泥石流";
    case "11D03":
      return "山体崩塌";
    case "11D04":
      return "地面塌陷";
    case "11D05":
      return "地裂缝";
    case "11D06":
      return "地面沉降";
    case "11D07":
      return "火山喷发";
    case "11D08":
      return "地质灾害气象风险";
    case "11D09":
      return "地质灾害气象";
    case "11D10":
      return "地质灾害";
    case "11D11":
      return "地质灾害风险";
    case "11D99":
      return "其它地质灾害";
    case "11E00":
      return "海洋灾害";
    case "11E01":
      return "海啸";
    case "11E02":
      return "风暴潮";
    case "11E03":
      return "海冰";
    case "11E04":
      return "巨浪";
    case "11E05":
      return "赤潮";
    case "11E06":
      return "海浪";
    case "11E07":
      return "台风海浪";
    case "11E08":
      return "海啸信息";
    case "11F15":
      return "农业气象灾害";
    case "11E99":
      return "其它海洋灾害";
    case "11F00":
      return "生物灾害";
    case "11F01":
      return "农业病害";
    case "11F02":
      return "农业虫害";
    case "11F03":
      return "农业草害";
    case "11F04":
      return "农业鼠害";
    case "11F05":
      return "森林病害";
    case "11F06":
      return "森林虫害";
    case "11F07":
      return "森林鼠害";
    case "11F08":
      return "农业转基因生物安全突发";
    case "11F09":
      return "林业转基因生物安全突发";
    case "11F10":
      return "林业有害植物";
    case "11F11":
      return "外来有害动植物威胁农业生产";
    case "11F12":
      return "外来有害动植物威胁林业生产";
    case "11F13":
      return "林业有害生物灾害预警";
    case "11F14":
      return "农作物重大病虫";
    case "11F99":
      return "其它生物灾害";
    case "11G00":
      return "森林草原火灾";
    case "11001":
      return "境内森林火灾";
    case "11002":
      return "跨境森林火灾";
    case "11003":
      return "境外威胁我国境内的森林火灾";
    case "11004":
      return "其他森林火灾";
    case "11005":
      return "境内草原火灾";
    case "11006":
      return "跨境草原火灾";
    case "11007":
      return "境外威胁我国境内的草原火灾";
    case "11008":
      return "其他草原火灾";
    case "11G09":
      return "森林火险预警";
    case "11G10":
      return "高森林火险";
    case "11G11":
      return "高森林火险天气警报";
    case "11G12":
      return "草原火灾";
    case "11G13":
      return "森林（草原）险情";
    case "11H00":
      return "农业气象灾害";
    case "11H01":
      return "早稻高温热害风险预警";
    case "11H02":
      return "一季稻高温热害风险预警";
    case "11H03":
      return "玉米高温热害风险预警";
    case "11H04":
      return "早稻播种育秧期低温冷害风险预警";
    case "11H05":
      return "晚稻寒露风灾害风险预警";
    case "11H06":
      return "东北初霜冻害风险预警";
    case "11H07":
      return "冬小麦晚霜冻害风险预警";
    case "11H08":
      return "玉米障碍型冷害风险预警";
    case "11H09":
      return "一季稻障碍型冷害风险预警";
    case "11H10":
      return "冬小麦湿渍害风险预警";
    case "11H11":
      return "夏玉米渍涝害风险预警";
    case "11H12":
      return "连阴雨灾害风险预警";
    case "11H13":
      return "农业干旱风险预警";
    case "11H14":
      return "高温热害风险预警";
    case "11H15":
      return "水稻春季低温风险预警";
    case "11H16":
      return "晚稻寒露风风险预警";
    case "11H17":
      return "早稻低温冷害风险预警";
    case "11H18":
      return "早稻春季连阴雨风险预警";
    case "11H19":
      return "晚稻干旱风险预警";
    case "11H20":
      return "农业干旱风险";
    case "11H21":
      return "霜冻风险";
    case "11H22":
      return "水稻障碍型冷害风险";
    case "11H23":
      return "农田渍涝风险";
    case "11J00":
      return "恶劣天气交通预警";
    case "11J01":
      return "路面结冰";
    case "11J02":
      return "道路浓雾";
    case "11J03":
      return "道路降雨";
    case "11J04":
      return "道路大风";
    case "11J05":
      return "道路降雪";
    case "11Y00":
      return "其他自然灾害";
    case "11Y01":
      return "国家救灾预警响应";
    case "11Y02":
      return "自然灾害救助";
    case "11Y03":
      return "海外自然灾害安全风险";
    case "11Y04":
      return "应急安全提醒";
    case "11Y05":
      return "其他灾害";
    case "11Y06":
      return "风险";
    case "11Y07":
      return "自然灾害综合预警信息";
    case "11Y08":
      return "温馨";
    case "11Y09":
      return "全国自然灾害综合风险预警";
    case "11Y10":
      return "强对流天气预警响应";
    case "11Y11":
      return "地磁暴";
    case "11Y12":
      return "耀斑";
    case "12000":
      return "事故灾难";
    case "12099":
      return "其它火灾事故";
    case "12A00":
      return "煤矿事故";
    case "12A01":
      return "煤矿瓦斯事故";
    case "12A02":
      return "煤矿顶板事故";
    case "12A03":
      return "煤矿运输事故";
    case "12A04":
      return "煤矿水害事故";
    case "12A05":
      return "煤矿机电事故";
    case "12A06":
      return "煤矿放炮事故";
    case "12A07":
      return "煤矿火灾事故";
    case "12A99":
      return "煤矿其他事故";
    case "12B00":
      return "金属与非金属矿山事故";
    case "12B01":
      return "金属与非金属矿顶板事故";
    case "12B02":
      return "金属与非金属矿水害事故";
    case "12B03":
      return "金属与非金属矿中毒和窒息事故";
    case "12B04":
      return "金属与非金属矿尾矿库垮坝事故";
    case "12B05":
      return "金属与非金属矿火灾事故";
    case "12B06":
      return "金属与非金属矿机电事故";
    case "12B07":
      return "金属与非金属矿运输事故";
    case "12B08":
      return "金属与非金属矿放炮事故";
    case "12B09":
      return "金属与非金属矿火药爆炸事故";
    case "12B99":
      return "金属与非金属矿山其他事故";
    case "12C00":
      return "建筑业事故";
    case "12C01":
      return "房屋建筑与市政工程施工安全事故";
    case "12C02":
      return "其他建筑施工安全事故";
    case "12D00":
      return "危险化学品事故";
    case "12D01":
      return "危险化学品爆炸事故";
    case "12D02":
      return "危险化学品泄漏事故";
    case "12D03":
      return "危险化学品火灾事故";
    case "12D04":
      return "危险化学品中毒和窒息事故";
    case "12D05":
      return "危险化学品灼烫事故";
    case "12D99":
      return "危险化学品其他事故";
    case "12E00":
      return "烟花爆竹和民用爆炸物事故";
    case "12E01":
      return "烟花爆竹生产企业爆炸事故";
    case "12E02":
      return "烟花爆竹运输爆炸事故";
    case "12E03":
      return "民用爆炸物爆炸事故";
    case "12E99":
      return "其他烟花爆竹事故";
    case "12F00":
      return "其他工矿商贸事故";
    case "12G00":
      return "火灾事故";
    case "12G01":
      return "一般工业建筑火灾";
    case "12G02":
      return "特种工业建筑火灾";
    case "12G03":
      return "一般民用建筑火灾";
    case "12G04":
      return "高层民用建筑火灾";
    case "12G05":
      return "地下建筑火灾";
    case "12G06":
      return "公用建筑火灾";
    case "12G07":
      return "隧道火灾";
    case "12G08":
      return "消防事故风险";
    case "12G99":
      return "其它火灾事故";
    case "12H00":
      return "道路交通事故";
    case "12H01":
      return "翻车帮件";
    case "12H02":
      return "撞车";
    case "12H03":
      return "车辆坠水、坠沟";
    case "12H04":
      return "车辆起火";
    case "12H05":
      return "校车交通事故";
    case "12H06":
      return "交通预警";
    case "12H07":
      return "道路交通安全";
    case "12H08":
      return "高速公路风险预警";
    case "12H10":
      return "交通事故风险";
    case "12H99":
      return "其他道路交通事故";
    case "12J11":
      return "渔船事故";
    case "12J00":
      return "水上交通事故";
    case "12J01":
      return "船舶碰撞事故";
    case "12J02":
      return "船舶触礁事故";
    case "12J03":
      return "船舶触损事故";
    case "12J04":
      return "船舶搁浅事故";
    case "12J05":
      return "船舶遭受风灾事故";
    case "12J06":
      return "船舶火灾事故";
    case "12J07":
      return "船舶失踪事故";
    case "12J08":
      return "船舶海上遇险事故";
    case "12J09":
      return "水上保安";
    case "12J10":
      return "沿海渔业设施事故";
    case "12J12":
      return "禁航通告";
    case "12J13":
      return "灾害";
    case "12J14":
      return "海浪引发事故灾难";
    case "12J15":
      return "风暴潮引发事故灾难";
    case "12J16":
      return "海上大风引发事故灾难";
    case "12J17":
      return "台风海浪引发事故灾难";
    case "12J18":
      return "风暴潮、海浪引发事故灾难";
    case "12J99":
      return "其他水上交通事故";
    case "12K00":
      return "铁路交通事故";
    case "12K01":
      return "列车脱轨事故";
    case "12K02":
      return "列车追尾事故";
    case "12K03":
      return "列车撞车事故";
    case "12K04":
      return "列车撞人事故";
    case "12K05":
      return "列车火灾、爆炸事故";
    case "12K99":
      return "其他铁路交通事故";
    case "12L00":
      return "城市轨道交通事故";
    case "12L01":
      return "地铁、轻轨、单轨列车脱轨事故";
    case "12L02":
      return "地铁、轻轨、单轨列车追尾事故";
    case "12L03":
      return "地铁、轻轨、单轨列车撞车事故";
    case "12L04":
      return "地铁、轻轨、单轨列车撞人事故";
    case "12L05":
      return "地铁、轻轨、单轨列车火灾、爆炸事故";
    case "12L99":
      return "其他城市轨道交通事故";
    case "12M00":
      return "民用航空器事故";
    case "12M01":
      return "坠机";
    case "12M02":
      return "撞机";
    case "12M99":
      return "其他民用航空器飞行事故";
    case "12N00":
      return "特种设备事故";
    case "12N01":
      return "锅炉事故";
    case "12N02":
      return "压力容器事故";
    case "12N03":
      return "压力管道事故";
    case "12N04":
      return "电梯事故";
    case "12N05":
      return "起重机械事故";
    case "12N06":
      return "客运索道事故";
    case "12N07":
      return "大型游乐设施事故";
    case "12N99":
      return "其他特种设备事故";
    case "12P00":
      return "基础设施和公用设施事故";
    case "12P01":
      return "公路交通设施事故";
    case "12P02":
      return "铁路交通设施事故";
    case "12P03":
      return "城市轨道交通设施事故";
    case "12P04":
      return "城市桥梁隧道设施事故";
    case "12P05":
      return "水运交通设施事故";
    case "12P06":
      return "民航交通设施事故";
    case "12P07":
      return "水利设施事故";
    case "12P08":
      return "电力基础设施事故";
    case "12P09":
      return "石油天然气基础设施事故";
    case "12P10":
      return "通讯基础设施事故";
    case "12P11":
      return "金融基础设施事故";
    case "12P12":
      return "城市生命线基础设施事故";
    case "12P13":
      return "建筑垮塌事故";
    case "12P14":
      return "电网电力供应";
    case "12P15":
      return "大面积停电";
    case "12P99":
      return "其他公用设施和设备事故";
    case "12Q00":
      return "环境污染和生态破坏";
    case "12Q01":
      return "水域污染";
    case "12Q02":
      return "空气污染";
    case "12Q03":
      return "土壤污染";
    case "12Q04":
      return "海上溢油";
    case "12Q05":
      return "污染导致城市水源供水中断事故";
    case "12Q06":
      return "转基因生物生态破坏";
    case "12Q07":
      return "盗伐、滥伐、哄抢森林";
    case "12Q10":
      return "毁林、乱占林地、非法改变林地用途";
    case "12Q11":
      return "濒危物种生存环境遭受环境污染";
    case "12Q12":
      return "野生动（植）物种群大批死亡";
    case "12Q13":
      return "自然保护区、风景名胜区生态破坏";
    case "12Q14":
      return "进口再生原料污染";
    case "12Q15":
      return "非法倾倒、埋藏剧毒危险废物";
    case "12Q16":
      return "重大林业生态破坏事故";
    case "12Q17":
      return "空气重污染";
    case "12Q18":
      return "大气污染";
    case "12Q19":
      return "重污染天气";
    case "12Q99":
      return "其它环境污染和生态破坏";
    case "12R00":
      return "农业机械事故";
    case "12R01":
      return "农业机械行驶事故";
    case "12R02":
      return "农业机械作业事故";
    case "12R03":
      return "农业机械碾压";
    case "12R04":
      return "农业机械碰撞";
    case "12R05":
      return "农业机械翻车";
    case "12R06":
      return "农业机械落车";
    case "12R07":
      return "农业机械火灾";
    case "12R99":
      return "其他农业机械事故";
    case "12T00":
      return "核与辐射事故";
    case "12T01":
      return "核设施事故";
    case "12T02":
      return "放射性物质运输事故";
    case "12T03":
      return "放射源事故";
    case "12T99":
      return "射线装置事故";
    case "12U00":
      return "能源供应中断事故";
    case "12Y00":
      return "其他事故灾难";
    case "12Y01":
      return "台风暴雨引发事故灾难";
    case "12Y02":
      return "台风引发事故灾难";
    case "12Y03":
      return "地质灾害引发事故灾难";
    case "12Y04":
      return "暴雨引发事故灾难";
    case "12Y05":
      return "暴雪引发事故灾难";
    case "12Y06":
      return "大雾引发事故灾难";
    case "12Y07":
      return "海外事故灾难安全风险";
    case "12Y08":
      return "其他灾难";
    case "12Y09":
      return "安全生产事故";
    case "12Y11":
      return "春季安全生产";
    case "12Y12":
      return "事故灾难综合预警信息";
    case "12Y13":
      return "防火安全";
    case "12Y14":
      return "节假日安全";
    case "12Y15":
      return "生产生活安全风险";
    case "12800":
      return "踩踏";
    case "12801":
      return "公园组织大型群众性活动或聚会踩踏";
    case "12802":
      return "校园踩踏";
    case "12899":
      return "其他踩踏";
    case "13000":
      return "公共卫生";
    case "13A00":
      return "传染病";
    case "13A01":
      return "鼠疫流行";
    case "13A02":
      return "霍乱流行";
    case "13A03":
      return "肺炭疽流行";
    case "13A04":
      return "传染性非典型肺炎流行";
    case "13A05":
      return "大感染高致病性禽流感流行";
    case "13A06":
      return "其他甲类或甲类管理传染病流行";
    case "13A07":
      return "其他乙类传染病流行";
    case "13A08":
      return "新传染病或我国尚未发现的传染病传入";
    case "13A09":
      return "我国己消灭传染病重新流行";
    case "13A10":
      return "新型冠状病毒肺炎";
    case "13A99":
      return "其它传染病流行";
    case "13B00":
      return "食品药品安全";
    case "13B01":
      return "药品安全";
    case "13B02":
      return "群体性预防接种反应";
    case "13B03":
      return "食品安全";
    case "13B04":
      return "农产品质量安全";
    case "13B05":
      return "药品不良反应";
    case "13B06":
      return "医疗器械不良";
    case "13B07":
      return "畜产品安全	";
    case "13B08":
      return "水产品安全";
    case "13B09":
      return "学生食品安全";
    case "13B99":
      return "其它食品药品安全";
    case "13C00":
      return "群体性中毒、感染";
    case "13C01":
      return "急性职业中毒";
    case "13C02":
      return "重金属中毒";
    case "13C03":
      return "非职业性一氧化碳中毒";
    case "13C99":
      return "其他群体性中毒感染";
    case "13D00":
      return "病原微生物、菌毒株";
    case "13D01":
      return "菌株、毒株、致病因子丢失";
    case "13D02":
      return "隐匿运输、邮寄病原体、生物毒素";
    case "13D03":
      return "医源性感染";
    case "13D99":
      return "其他病原微生物、菌毒株";
    case "13E00":
      return "动物疫情";
    case "13E01":
      return "高致病性禽流感";
    case "13E02":
      return "口蹄疫";
    case "13E03":
      return "疯牛病";
    case "13E04":
      return "猪瘟";
    case "13E05":
      return "新城疫";
    case "13E06":
      return "蓝舌病";
    case "13E07":
      return "动物布鲁氏菌病";
    case "13E08":
      return "动物结核病";
    case "13E09":
      return "狂犬病";
    case "13E10":
      return "动物炭瘟病";
    case "13E11":
      return "反鱼兽疫";
    case "13E12":
      return "我国未发的动物疫病传入";
    case "13E13":
      return "我国己消灭动物疫病重新流行";
    case "13E14":
      return "野生动物疫源疫病";
    case "13E15":
      return "动物疫情";
    case "13E16":
      return "饲料质量安全";
    case "13E99":
      return "其他动物疫情";
    case "13F00":
      return "群体性不明原因疾病";
    case "13Y00":
      return "其社会 他公共卫生";
    case "13Y01":
      return "海外公共卫生安全风险";
    case "13Y02":
      return "其他公共卫生";
    case "13Y03":
      return "热射病风险";
    case "13600":
      return "其它严重影响公共健康和卫生安全";
    case "14000":
      return "安全";
    case "14A00":
      return "群体性";
    case "14A0l":
      return "非法集会游行示威";
    case "14A02":
      return "集体上访请愿";
    case "14A03":
      return "冲击、围攻党政军机关和要害部门";
    case "14A04":
      return "大规模打、砸、抢、烧犯罪";
    case "14A05":
      return "群体性械斗、冲突";
    case "14A06":
      return "静坐";
    case "14A07":
      return "罢市、罢工";
    case "14A10":
      return "罢课";
    case "14A11":
      return "高校内聚集失控";
    case "14A12":
      return "高校校园网大范围串联、煽动和蛊惑信息";
    case "14A13":
      return "阻断交通";
    case "14A14":
      return "阻挠、妨碍国家重点建设工程施工";
    case "14A15":
      return "暴狱";
    case "14A16":
      return "聚众闹事";
    case "14A17":
      return "道路交通管制信息";
    case "14A18":
      return "出行提示";
    case "14A19":
      return "交通安全预警提示";
    case "14A99":
      return "其它群体";
    case "14B00":
      return "刑事案件";
    case "14B01":
      return "杀人案件";
    case "14B02":
      return "爆炸案件";
    case "14B03":
      return "放火案件";
    case "14B04":
      return "投放危险物质案件";
    case "14B05":
      return "以危害方法危害公共安全案件";
    case "14B06":
      return "绑架案件";
    case "14B07":
      return "抢劫、盗窃金融机构或运钞车案件";
    case "14B08":
      return "抢劫、走私、盗窃军(警〉用枪械案件";
    case "14B09":
      return "放射性材料被盗、丢失案件";
    case "14B10":
      return "炸药、雷管被盗、丢失案件";
    case "14B11":
      return "走私放射性材料案件";
    case "14B12":
      return "走私固体废物案件";
    case "14B13":
      return "制贩毒品案件";
    case "14B14":
      return "盗窃、出卖、泄露及丢失国家秘密案件";
    case "14B15":
      return "攻击破坏计算机网络案件";
    case "14B16":
      return "攻击破坏卫星通信、广播电视传输系统案件";
    case "14B17":
      return "制售假劣药品、医疗器械案件";
    case "14B18":
      return "制售不符合卫生标准、有毒有害食品";
    case "14B19":
      return "走私、骗汇、逃汇、洗钱案件";
    case "14B20":
      return "金融诈骗案";
    case "14B21":
      return "增值税发票及其他票证案";
    case "14B22":
      return "假劣种子、化肥、农药坑农案件";
    case "14B23":
      return "非法狗猎、采集保护野生动植物案件";
    case "14B24":
      return "破坏物种资源案件";
    case "14B25":
      return "偷渡案件";
    case "14B99":
      return "其它刑事案件";
    case "14C00":
      return "金融突发";
    case "14C01":
      return "银行业金融突发";
    case "14C02":
      return "证券业金融突发";
    case "14C03":
      return "保险业金融突发";
    case "14C04":
      return "外汇类突发";
    case "14C05":
      return "货币发行类突发";
    case "14C06":
      return "支付结算类突发";
    case "14C07":
      return "经济犯罪预警提示";
    case "14C99":
      return "其它金融突发";
    case "14D00":
      return "影响市场稳定的突发";
    case "14D01":
      return "粮食市场异常波动";
    case "14D02":
      return "生活必需品市场异常波动";
    case "14D03":
      return "天然气迎峰度冬";
    case "14D04":
      return "有序用电";
    case "14D99":
      return "其他影响市场稳定的突发";
    case "14E00":
      return "民族和宗教";
    case "14E01":
      return "民族分裂活动";
    case "14E02":
      return "宗教大规模非法聚会";
    case "14E03":
      return "民族冲突";
    case "14E04":
      return "宗教冲突";
    case "14E99":
      return "其它民族宗教";
    case "14F00":
      return "恐怖袭击";
    case "14F01":
      return "袭击公共聚集场所";
    case "14F02":
      return "袭击党政军首脑机关";
    case "14F03":
      return "袭击城市标志性建筑物";
    case "14F04":
      return "袭击国防设施";
    case "14F05":
      return "袭击宗教场所";
    case "14F06":
      return "袭击外交机构或国际组织";
    case "14F07":
      return "袭击重要经济目标";
    case "14F08":
      return "袭击重要基础设施";
    case "14F09":
      return "袭击城市基础设施";
    case "14F10":
      return "袭击交通工具";
    case "14F11":
      return "袭击重要计算机信息网络系统";
    case "14F12":
      return "袭击通信或新闻中枢";
    case "14F13":
      return "袭击重要核生化设施";
    case "14F14":
      return "袭击党政军要员";
    case "14F15":
      return "袭击外交人员";
    case "14F16":
      return "袭击平民";
    case "14F17":
      return "袭击宗教人士";
    case "14F18":
      return "袭击知名人士";
    case "14F19":
      return "袭击外国公民";
    case "14F20":
      return "核生化战剂袭击";
    case "14F21":
      return "劫持航空器";
    case "14F22":
      return "劫持船舶";
    case "14F23":
      return "劫持火车";
    case "14F24":
      return "袭击警卫对象、警卫现场";
    case "14F99":
      return "其它恐怖袭击";
    case "14G00":
      return "涉外";
    case "14G01":
      return "政治类涉外";
    case "14G02":
      return "经济类涉外";
    case "14G03":
      return "灾害事故卫生类涉外";
    case "14G04":
      return "恐怖暴力类涉外";
    case "14G05":
      return "境外敌对势力类涉外";
    case "14G06":
      return "社会安全类涉外";
    case "14G07":
      return "海外社会安全安全风险";
    case "14G99":
      return "其它涉外";
    case "14H00":
      return "信息安全";
    case "14H01":
      return "影响公共互联网骨干网的大规模网络病毒传播";
    case "14H02":
      return "针对公共互联网核心设备的网络攻击";
    case "14H03":
      return "针对国家重要信息系统的网络攻击入侵";
    case "14H04":
      return "重大网络安全威胁隐患及网络攻击类预警";
    case "14H05":
      return "警示";
    case "14H99":
      return "其他信息安全";
    case "14Y00":
      return "其他社会安全";
    case "14Y01":
      return "行政区划界限纠纷";
    case "14Y02":
      return "行政区划调整和地名变更引发";
    case "14Y03":
      return "旅游出行";
    case "14Y04":
      return "春运温馨提醒";
    case "14Y05":
      return "人防警报信息";
    case "14Y06":
      return "警报试鸣信息";
    case "14Y07":
      return "消防安全风险";
    case "14Y08":
      return "人员密集场所安全风险";
    case "14Y09":
      return "战时防空警报";
    case "14Y10":
      return "平时警报试鸣";
    case "14Y11":
      return "防空警报试鸣";
    case "14Y12":
      return "防台响应";
    case "14Y13":
      return "人防宣传教育";
    case "14Y14":
      return "消防提醒信息";
    case "14Y15":
      return "其他安全";
    case "14Y17":
      return "防灾减灾日科普宣传";
    case "14Y18":
      return "学生暑假安全";
    case "14Y19":
      return "学生防溺水安全";
    case "14Y16":
      return "防空警报";
    case "19000":
      return "其它突发";
    case "_":
      return "_";
  }
}
function formatPositionArr(arr) {
  var newArr = [];
  arr.forEach((item) => {
    if (item.cnty == "无") {
      item.cnty = "";
    }
    if (item.city == "无") {
      item.city = "";
    }
    item.location = `山西省${item.city}${item.cnty}`;
    newArr.push(item);
  });
  return newArr;
}

function getLongAndLati(item) {
  var geocodingTask = null;
  SGMap.plugin("SGMap.GeocodingPlusTask").then(function (res) {
    geocodingTask = new SGMap.GeocodingPlusTask({
      city: "山西",
      extensions: "base",
    });
    geocodingTask.getLocation(`${item.location}`).then(function (result) {
      if (result.info == "OK") {
        //获取经纬度成功，需要将经纬度数据从 "112.55241979659,37.867742881786" 形式转化为数组形式
        //result.geocodes[0].location.split(",")
        item.LongAndLati = result.geocodes[0].location.split(",");
      } else {
        //获取经纬度失败
        console.log("获取经纬度失败");
      }
    });
  });
}

function getLongAndLatiByNative(item, arr) {
  arr.forEach((loop) => {
    let loopLocation = `山西省${loop.location}`;
    if (loopLocation == item.location) {
      item.LongAndLati = loop.LongAndLati;
    }
  });
}

//找到离点击点最近的point
async function getPointDistance(pointClick, formatPosiArr) {
  await SGMap.plugin("SGMap.GeometryUtil").then(function (res) {
    for (let i = 0; i < formatPosiArr.length; i++) {
      let item = formatPosiArr[i];
      let distance = new SGMap.GeometryUtil().distance(
        pointClick,
        item.LongAndLati
      );
      item.distance = distance;
    }
  });
  return formatPosiArr.sort(compare("distance"))[0];
}

function compare(prop) {
  return function (obj1, obj2) {
    var val1 = obj1[prop];
    var val2 = obj2[prop];
    if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {
      val1 = Number(val1);
      val2 = Number(val2);
    }
    if (val1 < val2) {
      return -1;
    } else if (val1 > val2) {
      return 1;
    } else {
      return 0;
    }
  };
}

//将经纬度转化为文字位置
async function lngLatToLocation(lng, lat) {
  var resultGet = null;
  await SGMap.plugin("SGMap.GeocodingPlusTask").then(async function (res) {
    var geocodingPlusTask = new SGMap.GeocodingPlusTask({
      city: "山西省",
      extensions: "all",
    });
    await geocodingPlusTask.getAddress(`${lng},${lat}`).then(function (result) {
      console.log(result);
      resultGet = result;
    });
  });
  return resultGet;
}
async function lngLatToLocationFormattedAddress(lng, lat) {
  var resultGet = null;
  await SGMap.plugin("SGMap.GeocodingPlusTask").then(async function (res) {
    var geocodingPlusTask = new SGMap.GeocodingPlusTask({
      city: "山西省",
      extensions: "all",
    });
    await geocodingPlusTask.getAddress(`${lng},${lat}`).then(function (result) {
      resultGet = result;
    });
  });
  return resultGet.regeocodes[0].formatted_address;
}
//灾难对应表
function staDisasterMap(params) {
  var obj = {
    台风: "11B01",
    暴雨: "11B03",
    暴雪: "11B04",
    寒潮: "11B05",
    大风: "11B06",
    沙尘暴: "11B07",
    高温: "11B09",
    干旱: "11B14",
    雷电: "11B15",
    冰雹: "11B16",
    霜冻: "11B17",
    大雾: "11B19",
    霾: "11B20",
    道路结冰: "11B21",
    雷雨大风: "11B22",
    森林火险: "11B25",
  };

  return obj[params];
}

//将文字转换为经纬度
async function Convertlatitude(value) {
  var _this = this;
  var location = null;

  await SGMap.plugin("SGMap.GeocodingTask").then(async function (res) {
    var geocodingTask = new SGMap.GeocodingTask();
    await geocodingTask
      .getLocation({
        address: `${value[1].name + value[2].name}`,
        region: "山西",
        isEncode: false,
      })
      .then(function (result) {
        location = result.location;
      });
  });

  return location;
}
export {
  getDwType,
  formatPositionArr,
  getLongAndLati,
  getLongAndLatiByNative,
  getPointDistance,
  lngLatToLocation,
  Convertlatitude,
  lngLatToLocationFormattedAddress,
  staDisasterMap,
};
